﻿using System;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class Show_DetailM : UserPage
{
    public DateTime max;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            max = GetMaxDate();
            UnlinkList.DataSource = GetDetail("断站");
            UnlinkList.DataBind();
            PowerList.DataSource = GetDetail("停电");
            PowerList.DataBind();
            WaveList.DataSource = GetDetail("驻波");
            WaveList.DataBind();
            Mtitle.InnerText = ConfigurationManager.AppSettings["SystemName"].Substring(0, 6);
            MFoot.InnerText = DateTime.Now.Year.ToString() + "©"
                + ConfigurationManager.AppSettings["CompanyName"] + "Gt";
        }
    }

    private DataSet GetDetail(string argAlarm)
    {
        string sqlstr = "AB_GetInfo_Pk.GetAlarm";
        OracleParameter[] _params = {
                new OracleParameter("V_Type",OracleType.VarChar,100),
                new OracleParameter("v_County",OracleType.VarChar,20),
                new OracleParameter("v_Cell",OracleType.VarChar,200),
				new OracleParameter("V_Begin",OracleType.VarChar,100),
				new OracleParameter("V_End",OracleType.VarChar,100),
				new OracleParameter("V_Net",OracleType.VarChar,20),
                new OracleParameter("V_IFLike",OracleType.VarChar,2),
                new OracleParameter("V_IFRevor",OracleType.VarChar,2),
				new OracleParameter("resultSet",OracleType.Cursor)
            };
        _params[0].Value = argAlarm;
        _params[1].Value = Request.QueryString["county"].ToString();
        _params[2].Value = Request.QueryString["cell"].ToString();
        _params[3].Value = max.ToString("yyyy-MM-dd");
        _params[4].Value = max.AddDays(1).ToString("yyyy-MM-dd");
        _params[5].Value = Request.QueryString["type"].ToString();
        _params[6].Value = "N";
        _params[7].Value = "0";
        _params[8].Direction = ParameterDirection.Output;
        return OracleHelper.ExecuteDataSet(sqlstr, CommandType.StoredProcedure, _params);
    }

    private DateTime GetMaxDate()
    {
        string sqlstr = "select MAX(maxdate) as maxadte from AB_UPLOAD_LOG_T";
        string date = OracleHelper.ExecuteScalar(sqlstr, CommandType.Text, null).ToString();
        return DateTime.Parse(date);
    }
}
